<!--
	This file is part of ELCube.
	ELCube is free software: you can redistribute it and/or modify
	it under the terms of the GNU Affero General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.
	ELCube is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Affero General Public License for more details.
	You should have received a copy of the GNU Affero General Public License
	along with ELCube.  If not, see <https://www.gnu.org/licenses/>.
-->
<template>
    <nk-card>
        <vxe-table
                ref="xTable"
                row-key
                auto-resize
                keep-source
                resizable
                size="mini"
                border=inner
                :data="list">
            <vxe-column field="key"          width="25%"  title="KEY"></vxe-column>
            <vxe-column field="name"         width="25%" title="变量" ></vxe-column>
            <vxe-column field="value"        width="15%" title="值" >
                <template v-slot="{row}">
                    <span v-if     ="row.format === 'nkNumber'">{{row.value | nkNumber}}</span>
                    <span v-else-if="row.format === 'nkPercent'">{{row.value | nkPercent}}</span>
                    <span v-else-if="row.format === 'nkCurrency'">{{row.value | nkCurrency}}</span>
                    <span v-else-if="row.format === 'nkDatetime'">{{row.value | nkDatetime}}</span>
                    <span v-else>{{row.value}}</span>
                </template>
            </vxe-column>
            <vxe-column field="desc"         title="描述" ></vxe-column>
        </vxe-table>
    </nk-card>
</template>

<script>
    import Mixin from "Mixin";

    export default {
        mixins:[new Mixin()],
        computed:{
            list(){
                return this.data && this.def.vars && this.def.vars.map(v=>{
                    const value = this.data[v.key];
                    return Object.assign({value},v);
                });
            }
        }
    }
</script>

<style scoped>

</style>